<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理</title>
#include("../jscss.html")
<script type="text/javascript">
	$(function(){
		//查询结果表格
		var grid = $('#data-grid');
		grid.datagrid({
			border:false,
			columns:[[
			    {field:'ck',checkbox:true},
			    {field:"id", title:"ID", hidden:'true'},
			    {field:'bank',title:'归属',sortable : true},
				{field:'packageCode',title:'包裹编号',width:100,formatter:function(val,row){
					return '<a href="modify?packageinfo.id='+row.id+'">'+val+'</a>'
				}},
				{field: "type",title:'类型',width:60,sortable : true, hidden:'true'},
				{field:"network",title:'网点',width:160,sortable : true},
				{field:'department',title:'部门',width:60, hidden:'true'},
				{field:'business',title:'业务',width:60},
				{field:'state',title:'状态',width:60,sortable : true},
				{field:'location',title:'位置',width:160},
			]],
			fit:true,
			pagination:true,
			rownumbers:true,
			url:'packageinfoList',
			pageList:[10,20,30,50,100],
			pageSize:20,
			toolbar:'#tb',
			singleSelect:true,
			nowrap:false,
			striped:true
		});
		
		$('#search').click(function(){
			var jsonParam = $('#search-form').serializeJsonNotNull();
			grid.datagrid('load', jsonParam);
		});
		$('#edite').click(function(){
			if($('#data-grid').datagrid('getSelected')==null){
				$.messager.alert('提醒','请选择一条修改的数据')
				return false;
			}
			window.location.replace('modify?packageinfo.id='+$('#data-grid').datagrid('getSelected').id);
		});
		$('#del').click(function(){
			if($('#data-grid').datagrid('getSelected')==null){
				$.messager.alert('提醒','请选择要删除的数据')
				return false;
			}
			$.messager.confirm("操作提示", "您确定要执行删除操作吗？", function (data) {
	            if (data) {
					$.messager.progress({
						title:'请等待',
						msg:'数据提交中...'
					});
					$.post('delete',{"packageinfo.id":$('#data-grid').datagrid('getSelected').id},function(data){
						$.messager.progress('close');
						if(data.result==0){
							$.messager.alert('提醒','删除成功')
							grid.datagrid('load');
						}else{
							$.messager.alert("提醒","存在该包裹的物流信息，无法删除，如有必要，请将包裹的状态设置为停用")
						}
					},'json');
	            }
	        });
		});
	});
	
	function newPackage(){
		window.location.replace('add');
	}
</script>
</head>
<body>
	<table id="data-grid">
	</table>
	<div id="tb" style="padding: 5px; height: auto">
		<div>
			<form id="search-form">
			网点: <input class="easyui-textbox" type="text" name="network" style="width: 120px">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="search">查询</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="newPackage()">添加</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" id="edite">修改</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" id="del">删除</a>
			</form>
		</div>
	</div>
</body>
</html>